package com.rtx.wcs.std.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rtx.api.annotation.DataSourceAnnotation;
import com.rtx.wcs.std.bean.po.EdiTaskDownLog;
import com.rtx.wcs.std.mapper.EdiTaskDownLogMapper;
import com.rtx.wcs.std.service.EdiTaskDownLogService;

@Service
public class EdiTaskDownLogServiceImpl extends ServiceImpl<EdiTaskDownLogMapper, EdiTaskDownLog> implements EdiTaskDownLogService{

	
	@Transactional
	@DataSourceAnnotation
	@Override
	public void insertLog(String datasourcekey, List<EdiTaskDownLog> list) {
		for(EdiTaskDownLog log:list) {
			this.save(log);
		}
	}

	@DataSourceAnnotation
	@Override
	public void insertLog(String datasourcekey, EdiTaskDownLog log) {
		this.save(log);
	}

    @Override
    public void selectPageList(Page<EdiTaskDownLog> pageParam, EdiTaskDownLog dto) {
        LambdaQueryWrapper<EdiTaskDownLog> query = new LambdaQueryWrapper<>();
        //排序方式：按日志流水号降序排序
        query.orderByDesc(EdiTaskDownLog::getSerialkey);
        
        query.like(StringUtils.hasLength(dto.getApiname()),EdiTaskDownLog::getApiname, dto.getApiname());
        query.like(StringUtils.hasLength(dto.getRiswmsrequest()),EdiTaskDownLog::getRiswmsrequest, dto.getRiswmsrequest());
        query.like(StringUtils.hasLength(dto.getEdiresponse()),EdiTaskDownLog::getRiswmsrequest, dto.getRiswmsrequest());
        
        baseMapper.selectPage(pageParam,query);
    }
}
